<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button onclick="add()">新增</button>
    <button onclick="show()">显示</button>
    <script>
        // 保存学生信息
        // 新增学生信息
        var stuList = [];
        function add () {
            var name = prompt('请输入新生姓名：');
            var sex = prompt('请输入新生性别：');
            var info = {
                name: name,
                sex: sex
            }
            stuList.push(info)
        }
        function show () {
            document.write(stuList[0].name);
            document.write(stuList[0].sex);
        }
    </script>
</body>
</html>